<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--      <el-form-item label="学生姓名" prop="studentName">-->
<!--        <el-input-->
<!--          v-model="queryParams.studentName"-->
<!--          placeholder="请输入学生姓名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="所属阶段" prop="stage">-->
<!--        <el-input-->
<!--          v-model="queryParams.stage"-->
<!--          placeholder="请输入所属阶段"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="月份" prop="month">-->
<!--        <el-input-->
<!--          v-model="queryParams.month"-->
<!--          placeholder="请输入月份"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="自评-学习态度" prop="evaluateStudy">-->
<!--        <el-input-->
<!--          v-model="queryParams.evaluateStudy"-->
<!--          placeholder="请输入自评-学习态度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="自评-努力态度" prop="evaluateEfforts">-->
<!--        <el-input-->
<!--          v-model="queryParams.evaluateEfforts"-->
<!--          placeholder="请输入自评-努力态度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="自评-表达态度" prop="evaluateDeliver">-->
<!--        <el-input-->
<!--          v-model="queryParams.evaluateDeliver"-->
<!--          placeholder="请输入自评-表达态度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="创建人" prop="createby">-->
<!--        <el-input-->
<!--          v-model="queryParams.createby"-->
<!--          placeholder="请输入创建人"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="学生自己填写的存在问题" prop="studentProblem">-->
<!--        <el-input-->
<!--          v-model="queryParams.studentProblem"-->
<!--          placeholder="请输入学生自己填写的存在问题"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="学生自己填写改进的问题" prop="studentImprove">-->
<!--        <el-input-->
<!--          v-model="queryParams.studentImprove"-->
<!--          placeholder="请输入学生自己填写改进的问题"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="学生自己填写的加强的技能" prop="studentSkill">-->
<!--        <el-input-->
<!--          v-model="queryParams.studentSkill"-->
<!--          placeholder="请输入学生自己填写的加强的技能"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="学生自己填写的提供的帮助" prop="studentHelp">-->
<!--        <el-input-->
<!--          v-model="queryParams.studentHelp"-->
<!--          placeholder="请输入学生自己填写的提供的帮助"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="老师自己填写的学生存在的问题" prop="teacherProblem">-->
<!--        <el-input-->
<!--          v-model="queryParams.teacherProblem"-->
<!--          placeholder="请输入老师自己填写的学生存在的问题"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="老师自己填写的学生改进的地方" prop="teacherImprove">-->
<!--        <el-input-->
<!--          v-model="queryParams.teacherImprove"-->
<!--          placeholder="请输入老师自己填写的学生改进的地方"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item>-->
<!--        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
<!--        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
<!--      </el-form-item>-->
    </el-form>

<!--    <el-row :gutter="10" class="mb8">-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          icon="el-icon-plus"-->
<!--          size="mini"-->
<!--          @click="handleAdd"-->
<!--          v-hasPermi="['teaching:stage_investigate_detail:add']"-->
<!--        >新增</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="success"-->
<!--          plain-->
<!--          icon="el-icon-edit"-->
<!--          size="mini"-->
<!--          :disabled="single"-->
<!--          @click="handleUpdate"-->
<!--          v-hasPermi="['teaching:stage_investigate_detail:edit']"-->
<!--        >修改</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="danger"-->
<!--          plain-->
<!--          icon="el-icon-delete"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleDelete"-->
<!--          v-hasPermi="['teaching:stage_investigate_detail:remove']"-->
<!--        >删除</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="warning"-->
<!--          plain-->
<!--          icon="el-icon-download"-->
<!--          size="mini"-->
<!--          @click="handleExport"-->
<!--          v-hasPermi="['teaching:stage_investigate_detail:export']"-->
<!--        >导出</el-button>-->
<!--      </el-col>-->
<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
<!--    </el-row>-->

    <el-table v-loading="loading" :data="stage_investigate_detailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="所属阶段" align="center" prop="stage" />
      <el-table-column label="月份" align="center" prop="month" />
      <el-table-column label="自评-学习态度" align="center" prop="evaluateStudy" />
      <el-table-column label="自评-努力态度" align="center" prop="evaluateEfforts" />
      <el-table-column label="自评-表达态度" align="center" prop="evaluateDeliver" />
      <el-table-column label="反馈状态" align="center" prop="feedbackStatus" />
      <el-table-column label="创建人" align="center" prop="createBy" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['teaching:stage_investigate_detail:edit']"
          >提交</el-button>
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-delete"-->
<!--            @click="handleDelete(scope.row)"-->
<!--            v-hasPermi="['teaching:stage_investigate_detail:remove']"-->
<!--          >删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改阶段问卷细节对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="70%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="30%">
        <el-form-item label="学生姓名" prop="studentName">
          <el-input v-model="form.studentName" placeholder="请输入学生姓名" disabled/>
        </el-form-item>
        <el-form-item label="所属阶段" prop="stage">
          <el-select v-model="form.stage" placeholder="请选择阶段" disabled>
          <el-option
            v-for="dict in dict.type.sys_stage"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"

          />
          </el-select>
        </el-form-item>
        <el-form-item label="月份" prop="month">
          <el-input v-model="form.month" placeholder="请输入月份" disabled/>
        </el-form-item>
        <el-form-item label="自评-学习态度" prop="evaluateStudy">
          <el-select v-model="form.evaluateStudy" placeholder="请选择" clearable>
          <el-option
            v-for="dict in dict.type.ya_learn_attitude"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
          </el-select>
        </el-form-item>
        <el-form-item label="自评-努力态度" prop="evaluateEfforts">
          <el-select v-model="form.evaluateEfforts" placeholder="请选择" clearable>
            <el-option
              v-for="dict in dict.type.ya_effort"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="自评-表达态度" prop="evaluateDeliver">
          <el-select v-model="form.evaluateDeliver" placeholder="请选择" clearable>
            <el-option
              v-for="dict in dict.type.ya_expression"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="学生自己填写的存在问题" prop="studentProblem">
          <el-input v-model="form.studentProblem" placeholder="请输入学生自己填写的存在问题" />
        </el-form-item>
        <el-form-item label="学生自己填写改进的问题" prop="studentImprove">
          <el-input v-model="form.studentImprove" placeholder="请输入学生自己填写改进的问题" />
        </el-form-item>
        <el-form-item label="学生自己填写的加强的技能" prop="studentSkill">
          <el-input v-model="form.studentSkill" placeholder="请输入学生自己填写的加强的技能" />
        </el-form-item>
        <el-form-item label="学生自己填写的提供的帮助" prop="studentHelp">
          <el-input v-model="form.studentHelp" placeholder="请输入学生自己填写的提供的帮助" />
        </el-form-item>
<!--        <el-form-item label="老师自己填写的学生存在的问题" prop="teacherProblem">-->
<!--          <el-input v-model="form.teacherProblem" placeholder="请输入老师自己填写的学生存在的问题" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="老师自己填写的学生改进的地方" prop="teacherImprove">-->
<!--          <el-input v-model="form.teacherImprove" placeholder="请输入老师自己填写的学生改进的地方" />-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listStage_investigate_detail, getStage_investigate_detail, delStage_investigate_detail, addStage_investigate_detail, updateStage_investigate_detail } from "@/api/teaching/stage_investigate_detail";

export default {
  dicts: ['sys_stage','ya_expression','ya_weekday','ya_effort','ya_task_qualified','ya_learn_attitude'],
  name: "Stage_investigate_detail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 阶段问卷细节表格数据
      stage_investigate_detailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        studentName: null,
        stage: null,
        month: null,
        evaluateStudy: null,
        evaluateEfforts: null,
        evaluateDeliver: null,
        feedbackStatus: null,
        createBy: null,
        studentProblem: null,
        studentImprove: null,
        studentSkill: null,
        studentHelp: null,
        teacherProblem: null,
        teacherImprove: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询阶段问卷细节列表 */
    getList() {
      this.loading = true;
      listStage_investigate_detail(this.queryParams).then(response => {
        this.stage_investigate_detailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        studentName: null,
        stage: null,
        month: null,
        evaluateStudy: null,
        evaluateEfforts: null,
        evaluateDeliver: null,
        feedbackStatus: null,
        createBy: null,
        createTime: null,
        studentProblem: null,
        studentImprove: null,
        studentSkill: null,
        studentHelp: null,
        teacherProblem: null,
        teacherImprove: null,
        stageInvestigateId:null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加阶段问卷细节";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getStage_investigate_detail(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "提交个人阶段问卷";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateStage_investigate_detail(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStage_investigate_detail(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除阶段问卷细节编号为"' + ids + '"的数据项？').then(function() {
        return delStage_investigate_detail(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('teaching/stage_investigate_detail/export', {
        ...this.queryParams
      }, `stage_investigate_detail_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
